﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RegisterationCommon.School;
using System.Data;
using RegisterationCommon.Common;

namespace RegisterationSystem.Space_School
{
    public partial class maintenance : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Bind();
            }
        }
        //绑定学校信息
        void Bind()
        {
            SchoolInfo s = new SchoolInfo();
            if (s.GetSchoolInfoByID(Convert.ToInt32(Cookies.Get("SchID"))))
            {
                lblname.Text = s.Name;
                lblnum.Text = s.Count.ToString();
                txtIntro.Text = s.Intro;
                txtWebsite.Text = s.Website;
                txtAddress.Text = s.Address;
                txtTelphone.Text = s.Telphone;
                txta.Text = s.AInfo;
                txtb.Text = s.BInfo;
                txtc.Text = s.CInfo;
               // txtd.Text = s.DInfo;
            }

        }
        //修改
        protected void btnupd_Click(object sender, EventArgs e)
        {
            SchoolInfo s = new SchoolInfo();
            RParams RP = new RParams();
            RP.Add("ID", Convert.ToInt32(Cookies.Get("SchID")), SqlDbType.Int);
            RP.Add("Intro", txtIntro.Text, SqlDbType.VarChar);
            RP.Add("Website", txtWebsite.Text, SqlDbType.VarChar);
            RP.Add("Address", txtAddress.Text, SqlDbType.VarChar);
            RP.Add("Telphone", txtTelphone.Text, SqlDbType.VarChar);
            RP.Add("AInfo", txta.Text, SqlDbType.VarChar);
            RP.Add("BInfo", txtb.Text, SqlDbType.VarChar);
            RP.Add("CInfo", txtc.Text, SqlDbType.VarChar);
          //  RP.Add("DInfo", txtd.Text, SqlDbType.VarChar);
            string colFields = "Intro,Website,Address,Telphone,AInfo,BInfo,CInfo";
            string whereFields = "ID=@ID";
            if (s.MdfSchoolInfo(colFields, whereFields, RP))
            {
                Message.Send(10025);
            }
            else
            {
                Message.Send(10026);
            }
        }
    }
}